﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Base;

namespace ConAppCore
{
    internal class TestPathEx
    {
        public static void Test()
        {
            string path = PathEx.ExecutablePath;

            //string curDir1 = Directory.GetCurrentDirectory();
            //string dir1 = PathEx.GetEntryAssemblyDirectory();
            //Directory.SetCurrentDirectory(@"E:\Code\ZHN\UtilZ.NativeEx\x64\Debug");
            //string curDir2 = Directory.GetCurrentDirectory();
            //string dir2 = PathEx.GetEntryAssemblyDirectory();

            var ret1 = Path.GetFileName(@"E:\Code\ZHN\UtilZ.NativeEx\x64\Debug");
            var ret2 = Path.GetPathRoot(@"E:\Code\ZHN\UtilZ.NativeEx\x64\Debug");
            //TestCombine();
            TestGetLastPathName();
        }

        private static void TestMember()
        {
            //Path.AltDirectorySeparatorChar
            //Path.DirectorySeparatorChar
            //Path.Combine();
            //Path.ChangeExtension();
            //Path.Exists();
            //Path.GetDirectoryName();
            //Path.GetExtension();
            //Path.GetFileName();
            //Path.GetFullPath();
            //Path.GetExtension();
            //Path.GetFileNameWithoutExtension();
            //Path.GetInvalidFileNameChars();
            //Path.GetInvalidPathChars();
            //Path.GetPathRoot();
            //Path.GetRandomFileName();
            //Path.GetRelativePath();
            //Path.GetTempFileName();
            //Path.GetTempPath();
            //Path.HasExtension();
            //Path.Join();


            //PathEx.ToWebPath();
            //PathEx.ToLocalPath();
            //PathEx.Combine();
            //PathEx.GetPathSeparatorChar();
            //PathEx.GetFullPath();
            //PathEx.GetEntryAssemblyDirectory();

            //DirectoryInfoEx.CheckDirectory();
            //DirectoryInfoEx.OpenFileDirectory();
            //DirectoryInfoEx.CheckFilePathDirectory();
            //DirectoryInfoEx.CopyFolder();
            //DirectoryInfoEx.GetFullPath();

            //File.Exists();
            //File.Delete(Path);
            //File.WriteAllLines();
            //File.WriteAllText();
            //File.Move();
            //File.AppendAllLines();
            //File.AppendAllText();
            //File.AppendText();
            //File.Copy(Path);
            //File.Create();
            //File.CreateText();
            //File.Delete(Path);

            //File.GetCreationTime();
            //File.GetLastAccessTime();
            //File.GetLastWriteTime();
            //File.SetCreationTime();
            //File.SetLastAccessTime();
            //File.SetLastWriteTime();

            //File.Open();
            //File.OpenRead();
            //File.OpenWrite();
            //File.OpenText();
            //File.ReadAllBytes();
            //File.ReadAllLines();
            //File.ReadAllText();




            //Directory.Delete();
            //Directory.CreateDirectory();
            //Directory.Exists();
            //Directory.SetCurrentDirectory();
            //Directory.GetCurrentDirectory();

            //Directory.GetCreationTime();
            //Directory.GetLastAccessTime();
            //Directory.GetLastWriteTime();
            ///Directory.SetCreationTime();
            //Directory.SetLastAccessTime();
            //Directory.SetLastWriteTime();

            //Directory.GetParent();
            //Directory.GetFiles();
            //Directory.GetDirectories();
            //Directory.GetDirectoryRoot();
            //Directory.GetFileSystemEntries();
            //Directory.Move();


            //FileSystemInfo ->DirectoryInfo and FileInfo

            //DirectoryInfo dirInfo = null;
            //dirInfo.Create();
            //dirInfo.Delete();
            //dirInfo.Exists();
            //dirInfo.Parent
            //dirInfo.GetFiles();
            //dirInfo.GetDirectories();
            //dirInfo.FullName
            //dirInfo.GetCreationTime();
            //dirInfo.GetLastAccessTime();
            //dirInfo.GetLastWriteTime();
            //dirInfo.SetCreationTime();
            //dirInfo.SetLastAccessTime();
            //dirInfo.SetLastWriteTime();


            //FileInfo fileInfo = null;
            //fileInfo.Exists
            //fileInfo.Extension
            //fileInfo.Delete
            //fileInfo.Directory
            //fileInfo.Create();
            //fileInfo.CreateText();
            //fileInfo.AppendText();
            //fileInfo.CopyTo()
            //fileInfo.DirectoryName
            //fileInfo.FullName
            //fileInfo.Length
            //fileInfo.MoveTo
            //fileInfo.Name
            //fileInfo.Open();
            //fileInfo.OpenRead();
            //fileInfo.OpenText();
            //fileInfo.OpenWrite();

        }

        private static void TestGetLastPathName()
        {
            string ret1 = PathEx.GetLastPathName(@"D:\123");
            string ret2 = PathEx.GetLastPathName(@"D:\123\abc");
            string ret3 = PathEx.GetLastPathName(@"123\abc");
            string ret4 = PathEx.GetLastPathName(@"abc");
            string ret5 = PathEx.GetLastPathName(@"/abc");
            string ret6 = PathEx.GetLastPathName(@"\abc");
            string ret7 = PathEx.GetLastPathName(@"D:/123");
            string ret8 = PathEx.GetLastPathName(@"D:/123/abc");
            string ret9 = PathEx.GetLastPathName(@"D:/");
            string ret10 = PathEx.GetLastPathName(@"D:\");


            string ret11 = PathEx.GetLastPathName(@"/home/abc");
            string ret12 = PathEx.GetLastPathName(@"\home\abc");
            string ret13 = PathEx.GetLastPathName(@"\");
            string ret14 = PathEx.GetLastPathName(@"/");
        }

        private static void TestCombine()
        {
            string ret81 = PathEx.Combine(PathType.Web, @"/", "\\", "//", "AA/", "/BB", "/CC/", "\\DD", "EE\\", "\\FF\\");

            string ret55 = PathEx.Combine(PathType.Web, @"\SelfCode", "/");
            string ret56 = PathEx.Combine(PathType.Web, @"\SelfCode", "\\");
            string ret57 = PathEx.Combine(PathType.Web, @"/SelfCode\", "/");
            string ret58 = PathEx.Combine(PathType.Web, @"/SelfCode\", "\\");
            string ret59 = PathEx.Combine(PathType.Web, @"\SelfCode", "/");
            string ret511 = PathEx.Combine(PathType.Web, @"\SelfCode", "\\");
            string ret512 = PathEx.Combine(PathType.Web, @"/SelfCode\", "/");
            string ret513 = PathEx.Combine(PathType.Web, @"/SelfCode\", "\\");

            string ret61 = PathEx.Combine(PathType.Web, @"/", "SelfCode");
            string ret62 = PathEx.Combine(PathType.Web, @"/", "\\SelfCode");
            string ret63 = PathEx.Combine(PathType.Web, @"/", "/SelfCode");
            string ret64 = PathEx.Combine(PathType.Web, @"/", "SelfCode\\");
            string ret65 = PathEx.Combine(PathType.Web, @"/", "SelfCode/");

            string ret71 = PathEx.Combine(PathType.Web, @"\\", "SelfCode");
            string ret72 = PathEx.Combine(PathType.Web, @"\\", "\\SelfCode");
            string ret73 = PathEx.Combine(PathType.Web, @"\\", "/SelfCode");
            string ret74 = PathEx.Combine(PathType.Web, @"\\", "SelfCode\\");
            string ret75 = PathEx.Combine(PathType.Web, @"\\", "SelfCode/");




            string ret1 = Path.Combine("testApi", "getName");
            string ret2 = Path.Combine("/testApi", "getName");
            string ret3 = Path.Combine("testApi", "/getName");
            string ret4 = Path.Combine("/testApi", "/getName");

            string ret21 = Path.Combine("testApi", "getName");
            string ret22 = Path.Combine(@"\testApi", "getName");
            string ret23 = Path.Combine("testApi", @"\getName");
            string ret24 = Path.Combine(@"\testApi", @"\getName");

            string ret31 = PathEx.Combine(PathType.Web, "testApi", "getName");
            string ret32 = PathEx.Combine(PathType.Web, "/testApi", "getName");
            string ret33 = PathEx.Combine(PathType.Web, "testApi", "/getName");
            string ret34 = PathEx.Combine(PathType.Web, "/testApi", "/getName");

            string ret35 = PathEx.Combine(PathType.Web, "testApi/", "getName");
            string ret36 = PathEx.Combine(PathType.Web, "/testApi", "getName/");
            string ret37 = PathEx.Combine(PathType.Web, "testApi/", "/getName/");
            string ret38 = PathEx.Combine(PathType.Web, "/testApi/", "/getName/");

            string ret39 = PathEx.Combine(PathType.Local, @"D:\SelfCode", "/getName/");
            string ret40 = PathEx.Combine(PathType.Local, @"D:\SelfCode\", "/getName/");
            string ret41 = PathEx.Combine(PathType.Local, @"D:\SelfCode\", "/");
            string ret42 = PathEx.Combine(PathType.Local, @"D:\SelfCode\", "\\");
            //ret42   D:\SelfCodeHttpServerSlnConsoleAppWebServerhtmls\qwe.html
            string ret43 = PathEx.Combine(PathType.Local, @"D:\SelfCode\HttpServerSln\ConsoleAppWebServer\htmls", @"\qwe.html");

            string ret44 = PathEx.Combine(PathType.Web, "/testApi/", "{z}/{x}/{y}.png");

            string ret51 = PathEx.Combine(PathType.Local, @"D:\SelfCode", "/");
            string ret52 = PathEx.Combine(PathType.Local, @"D:\SelfCode\", "/");
            string ret53 = PathEx.Combine(PathType.Local, @"D:/SelfCode", "/");
            string ret54 = PathEx.Combine(PathType.Local, @"D:/SelfCode\", "/");

            //Directory.GetCurrentDirectory()
            //Directory.SetCurrentDirectory(PathEx.GetEntryAssemblyDirectory());

            var tmp = Path.GetFullPath(ret54);
        }
    }
}
